package com.liruo.learn.spring.mvc.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @Author:liruo
 * @Date:2023-03-09-23:03:42
 * @Desc
 */
@Order(-1)
@WebFilter(urlPatterns = "/*")
@Slf4j
public class FilterTest1 implements Filter{
    public FilterTest1() {
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        log.info("{} init", FilterTest1.class.getName());
    }

    @Override
    public void destroy() {
        log.info("{} destroy", FilterTest1.class.getName());
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        log.info("{} doFilter", FilterTest1.class.getName());
        filterChain.doFilter(servletRequest, servletResponse);
//        log.info("{} come back to doFilter", FilterTest1.class.getName());
    }
}
